package com.zkthink.ceres.member.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zkthink.base.R;
import com.zkthink.base.controller.SuperController;
import com.zkthink.base.controller.SuperSimpleController;
import com.zkthink.base.request.PageParams;
import com.zkthink.ceres.member.dto.*;
import com.zkthink.ceres.member.entity.Integral;
import com.zkthink.ceres.member.entity.MemberAddress;
import com.zkthink.ceres.member.service.IntegralService;
import com.zkthink.ceres.member.service.MemberAddressService;
import com.zkthink.security.annotation.PreAuth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * FileName: IntegralController
 * Author:   Pepis
 * Date:   2020  2020/8/29 15:45
 * Description: 会员积分 控制器
 **/
@Slf4j
@Validated
@RestController
@RequestMapping("/Integral")
@Api(value = "Integral", tags = "会员积分记录")
@PreAuth(replace = "Integral:")
public class IntegralController  {

    @Autowired
    private IntegralService integralService;

    /**
     * 分页查询
     */
//    @ApiOperation(value = "分页列表查询")
//    @PostMapping(value = "/page")
//    public R<IPage<IntegralPageDTO>> page(@RequestBody @Validated PageParams<IntegralPageDTO> params) {
//        // 处理参数
//        return R.success(integralService.page(params));
//    }

    /**
     * 查询 某个会员的 积分记录
     */
    @ApiOperation(value = "查询 某个会员的 积分记录")
    @GetMapping(value = "/getIntegralListByMID/{mid}")
    public R<List<Integral>> getIntegralListByMID(@PathVariable("mid")Long mid){
        return R.success(integralService.getIntegralListByMID(mid));
    }

    /**
     * 新增 积分记录
     */
    @ApiOperation(value = "新增 积分记录")
    @PostMapping
    public R save(@RequestBody @Validated IntegralSaveDTO entity){
        return integralService.save(entity);
    }
}
